/**
 * 
 */
package com.gragra.wilsHandler;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import com.gragra.sampling.sequentialStructure.ExtensionLevels;
import com.gragra.sampling.sequentialStructure.WordAndTagHolder;
import com.gragra.sampling.sequentialStructure.WordType;
import com.gragra.sequentiaDataGenerator.BaseGenerator;
import com.gragra.sequentiaDataGenerator.EmptySegmentation;
import com.gragra.util.StringToInt;

/**
 * @author Christoph Teichmann
 * 06.11.2013
 */
public class TypeTranscriber
{
	/**
	 * @param args
	 */
	public static void main(String[] args) throws IOException
	{
		BufferedReader universal = new BufferedReader(new FileReader(args[0]));
		BufferedReader toAnnotate = new BufferedReader(new FileReader(args[1]));
		BufferedWriter superTyped = new BufferedWriter(new FileWriter(args[2]));
		String line;
		BaseGenerator bg = new BaseGenerator(new EmptySegmentation());
		boolean first = true;
		while((line = toAnnotate.readLine()) != null)
		{
			WordAndTagHolder wta = bg.transferSingle(line);
			WordAndTagHolder uni = bg.transferSingle(universal.readLine());
			for(int i=0;i<wta.getLength();++i)
			{
				String tag  = StringToInt.reverse(uni.getTag(i));
				WordType wt = WordType.getTypeFor(tag);
				if(wt != null)
				{wta.getExtensionInformation().addInformation(i, ExtensionLevels.WordTypeLevel, wt);}
			}
			if(first)
			{first = false;}
			else
			{superTyped.newLine();}
			superTyped.write(BaseGenerator.transferToString(wta));
		}
		universal.close();
		toAnnotate.close();
		superTyped.close();
	}
}